/* Hao Hua He, SN: 020920435 */
/* Denys Silin, SN: 042080358 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

/* const BDSIZE=50; */


/* structure for the request record */
typedef struct { 
	char* date; 
	char* requestor; 
	char* email; 
	char* priority;
	char* needed;
	char* status;
	char* description;
	} ARecord;

/* data structure */ 
typedef struct {
	int status; 
	int pos;
	int len;
	ARecord data[50];
	} DataBlock;

DataBlock dbase;

/* load file into the memory, use at program start */
void db_open();

/* fW==0 memory write only, fW==1 synchronize memory list with file(use this with GUI)
 returns -1 if failed to add, note that you have to supply not the pointer, 
 but the existing record */
int db_add_record(ARecord newrec, int fW);

/* id is the number of the record in the list, starts with 0
 rec is returned with corresponding data
 function return -1 if incorrect id */
int db_show_record(int id, ARecord* rec); 

/* returns number of records */
int db_getsize();

/* returns record with desired Requestor, result will hold the found record
//or NULL if not found, function will return -1 if not found */
int db_search(char* requestor, ARecord* result);

/* nternal write function, do not use it */
void db_update();

/* use at program exit */
void db_close();


void chomp(char *s);